<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>React Router使用</title>
    <script src="https://cdn.bootcss.com/react/16.2.0/umd/react.development.js"></script>
    <script src="https://cdn.bootcss.com/react-dom/16.2.0/umd/react-dom.development.js"></script>

    <script src="https://cdn.bootcss.com/react-router/4.2.0/react-router.js"></script>
    <script src="https://cdn.bootcss.com/react-router-dom/4.2.2/react-router-dom.js"></script>

    <script src="https://cdn.bootcss.com/babel-standalone/6.26.0/babel.min.js"></script>

    <link href="https://cdn.bootcss.com/highlight.js/9.12.0/styles/vs2015.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/highlight.js/9.12.0/highlight.min.js"></script>

    <script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<div id="root"></div>

<p>代码</p>
<pre><code class="js">    ReactDOM.render(
        < h1 >欢迎使用React!< /h1>,
        document.getElementById('example')
    );
</code>
<script type="text/babel">
    const {
        BrowserRouter,
        Route,
        Link
    } = ReactRouterDOM;

    const Router = BrowserRouter;
    const App = () => (
        <Router>
            <div>
                <div>
                    <ul>
                        <li><Link to="/">首页</Link></li>
                        <li><Link to="/about">关于</Link></li>
                    </ul>
                    <hr />
                    <Route exact path="/" component={Home}/>
                    <Route path="/about" component={About}/>
                </div>
            </div>
        </Router>
    )

    const Home = () => (
        <div>
            <h2>首页</h2>
        </div>
    )

    const About = () => (
        <div>
            <h2>关于</h2>
        </div>
    )


    ReactDOM.render(
        <App />
        , document.getElementById('root')
    );
</script>

</body>
</html>